//
//  MoreViewController.m
//  味·道
//
//  Created by lanou3g on 15/6/30.
//  Copyright (c) 2015年 WMR. All rights reserved.
//

#import "MoreViewController.h"
#import "MaocHeader.h"
#import "FavoriteViewController.h"
#import "BrowseRecordViewController.h"
@interface MoreViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,retain)UITableView *tableView;
@end

@implementation MoreViewController
- (void)dealloc
{
    self.tableView = nil;
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self createTitleLabel];
    [self createTableView];
}
//创建标题
-(void)createTitleLabel{
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(150, 30, 80, 20)];
    titleLabel.textColor = [UIColor whiteColor];
    titleLabel.font = [UIFont boldSystemFontOfSize:18.0f];
    titleLabel.text = @"更多资讯";
    [self.view addSubview:titleLabel];
    [titleLabel release];
}
//创建tableView
-(void)createTableView{
    UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 55,SCREEN_WIDTH, SCREEN_HEIGHT-55) style:(UITableViewStyleGrouped)];
    tableView.delegate = self;
    tableView.dataSource = self;
//    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    self.tableView = tableView;
    [self.view addSubview:self.tableView];
    [tableView release];
    
}
#pragma mark - UITableViewDelegate,UITableViewDataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    switch (section) {
        case 0:
            return 2;
            break;
        case 1:
            return 3;
            break;
        case 2:
            return 2;
            break;
        default:
            break;
    }
    return 0;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (cell== nil) {
        cell = [[UITableViewCell alloc]initWithStyle:(UITableViewCellStyleValue1) reuseIdentifier:@"cell"];
    }
    switch (indexPath.section) {
        case 0:
            if (indexPath.row == 0) {
                cell.textLabel.text = @"精选收藏";
                cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                return cell;
            }else{
                cell.textLabel.text = @"浏览记录";
                cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                return cell;
            }
            break;
        case 1:
            if (indexPath.row == 0) {
                cell.textLabel.text = @"名称";
                cell.detailTextLabel.text = @"味·道";
                return cell;
            }else if (indexPath.row == 1){
                cell.textLabel.text = @"开发商";
                cell.detailTextLabel.text = @"蓝欧小组";
                return cell;
            }else{
                cell.textLabel.text = @"联系方式";
                cell.detailTextLabel.text = @"SHS150304@163.com";
                return cell;
            }
            break;
        case 2:
            if (indexPath.row == 0) {
                cell.textLabel.text = @"意见建议反馈";
                cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                return cell;
            }else{
                cell.textLabel.text = @"去AppStore给我们打分";
                cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                return cell;
            }
            break;
        default:
            break;
    }
    return cell;
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    NSString *titleStr = @"";
    switch (section) {
        case 0:
            titleStr = @"收藏与浏览记录";
            break;
        case 1:
            titleStr = @"开发者信息";
            break;
        case 2:
           titleStr = @"意见建议与BUG反馈";
            break;
        default:
            break;
    }
    return titleStr;
}
//选中触发事件
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            FavoriteViewController *favoriteVC = [[FavoriteViewController alloc] init];
            [self.rightVC.navigationController pushViewController:favoriteVC animated:YES];
        }else{
            BrowseRecordViewController *browseRecordVC = [[BrowseRecordViewController alloc] init];
            [self.rightVC.navigationController pushViewController:browseRecordVC animated:YES];
        }
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
